package com.cheney.common.sensitive.properties;

import ch.qos.logback.classic.spi.ILoggingEvent;
import com.cheney.common.sensitive.handler.LogbackMessageHandler;
import com.cheney.common.sensitive.strategy.SensitiveStrategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 脱敏配置项
 */
public class DefaultJsonProperties {

    /**
     * 当string类型字段的字段值是 一个json字符串时,是否对该内容中的敏感信息进行脱敏
     */
    private boolean hitStringValueIsJson = false;

    /**
     * 脱敏的策略 以及 对应的脱敏字段集合
     */
    private Map<SensitiveStrategy, Set<String>> strategies;

    /**
     * 指定短路插件
     * <p>
     * 当shortCircuitPlugins中存在{@link LogbackMessageHandler#support(ILoggingEvent)}匹配的插件时，
     * 使用该插件进行脱敏，而不用脱敏器进行脱敏
     * </p>
     */
    private List<LogbackMessageHandler> shortCircuitPlugins = new ArrayList<>();

    public boolean isHitStringValueIsJson() {
        return hitStringValueIsJson;
    }

    public void setHitStringValueIsJson(boolean hitStringValueIsJson) {
        this.hitStringValueIsJson = hitStringValueIsJson;
    }

    public Map<SensitiveStrategy, Set<String>> getStrategies() {
        return strategies;
    }

    public void setStrategies(Map<SensitiveStrategy, Set<String>> strategies) {
        this.strategies = strategies;
    }

    public List<LogbackMessageHandler> getShortCircuitPlugins() {
        return shortCircuitPlugins;
    }

    public void setShortCircuitPlugins(List<LogbackMessageHandler> shortCircuitPlugins) {
        this.shortCircuitPlugins = shortCircuitPlugins;
    }

    @Override
    public String toString() {
        return "DefaultJsonProperties{" +
                "hitStringValueIsJson=" + hitStringValueIsJson +
                ", strategies=" + strategies +
                '}';
    }
}